#include <bits/stdc++.h>
#define F(i,l,r) for(int i=(l);i<=(r);i++)
#define FF(i,r,l) for(int i=(r);i>=(l);i--)
#define M 100010
#define N 1000005

// #define ll long long
// //#define int long long
// #define pb(x) push_back(x)

using namespace std;
//const int mod

int T;
int n,m,L,V;
struct car{
    int dd,vv,aa;
}in[M];
int d[M],v[M],a[M];
int p[M];
int pp[N],s[N];
int ans1;
int cnt;
int tnt;

void work(){
    cin>>n>>m>>L>>V;
    for(int i=1;i<=n;i++){
        int x,y,z;
        cin>>x>>y>>z;
        if(y<=V&&z<=0){
            continue;
        }
        d[++cnt]=x;v[cnt]=y;a[cnt]=z;
    }
    F(i,1,m){
        cin>>p[i];
        pp[p[i]]++;
    }
    F(i,1,L){
        s[i]=s[i-1]+pp[i];
    }
    F(i,1,cnt){int delta;
        if(d[i]==0){
            tnt++;continue;
        }
        if(s[L]-s[d[i]-1]==0)continue;
        if(a[i]==0&&v[i]>V){
            in[++tnt].aa=a[i];in[tnt].vv=v[i];in[tnt].dd=d[i];continue;
        }
    }
    ans1=m-1;
    if(!tnt)ans1++;
    cout<<tnt<<' '<<ans1<<'\n';
}

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
    cin>>T;
    while(T--){
        work();
        F(i,1,cnt){
            d[i]=0;v[i]=0;a[i]=0;
        }
        cnt=0;tnt=0;
    }
    
    return 0;
}